<!DOCTYPE html>
<html>
<title>Create AppFuse Light Archetype</title>
<head>
    <style type="text/css">
        body {
            font-family: arial, sans-serif;
            font-size: 12px;
        }
        #mvncmd label {
            text-align: right;
            font-weight: bold;
            width: 180px;
            float: left;
            margin: 0 5px;
        }

        #mvncmd input, #mvncmd select, #mvncm span {
            width: 200px;
            margin-bottom: 5px;
            float: left;
        }

        #mvncmd textarea {
            width: 400px;
            height: 100px;
            color: blue;
        }

        #mvncmd br {
            clear: both;
        }

        #mvncmd div {
            float: left;
        }
    </style>
</head>
<body>
<div id="mvncmd">
    <div>
        <label for="groupId" title="Base Package">GroupId:</label>
        <input type="text" id="groupId" value="com.mycompany" onkeyup="changeIt();">

        <span title="Base Package">&nbsp;(?)</span><br/>
        <label for="artifactId" title="Project Name"> ArtifactId:</label>
        <input type="text" id="artifactId" value="myproject" onkeyup="changeIt();">
        <span title="Project Name">&nbsp;(?)</span><br/>
        <label for="version" title="AppFuse Light Version">Version:</label>
        <select id="version" onchange="changeIt();">
            <option value="3.5.1-SNAPSHOT">3.5.1-SNAPSHOT</option>
            <option value="3.5.0" selected="selected">3.5.0</option>
            <option value="2.2.1">2.2.1</option>
            <option value="2.1.0">2.1.0</option>
        </select><span title="AppFuse Light Version">&nbsp;(?)</span><br/>
        <label for="webFramework" title="Web Framework">Web Framework:</label>
        <select id="webFramework" onchange="changeIt();">
            <option value="jsf">JSF</option>
            <option value="spring">Spring MVC</option>
            <option value="spring-freemarker">Spring MVC + FreeMarker</option>
            <option value="spring-security">Spring MVC + Spring Security</option>
            <option value="stripes">Stripes</option>
            <option value="struts" selected="selected">Struts 2</option>
            <option value="tapestry">Tapestry 5</option>
            <option value="wicket">Wicket</option>
        </select><span title="Web Framework">&nbsp;(?)</span>
    </div>
    <div>
        <label for="cmdLine" id="cmdLabel">Command Line:</label>
        <textarea id="cmdLine" onfocus="this.select();"></textarea>
    </div>
    <script type="text/javascript">
        function changeIt() {
            var groupId = document.getElementById("groupId").value;
            var artifactId = document.getElementById("artifactId").value;
            var version = document.getElementById("version").value;
            var webFramework = document.getElementById("webFramework").value;
            var archetypeArtifactId = "appfuse-light-";

            archetypeArtifactId += webFramework;
            if (version.match(/.*SNAPSHOT/) || parseFloat(version.substring(0,3)) >= 2.1) archetypeArtifactId += "-archetype";
            var cmd = 'mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=' + archetypeArtifactId + ' -DarchetypeVersion=' + version + ' -DgroupId=' + groupId + ' -DartifactId=' + artifactId;
            if (version.match(/.*SNAPSHOT/)) cmd += ' -DarchetypeRepository=http://oss.sonatype.org/content/repositories/appfuse';
            document.getElementById("cmdLine").value = cmd;
        }

        changeIt();
    </script>
</div>
</body>
</html>